﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPages_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["back_url"] = "~/public/categorydish.aspx";

            PreRender += new EventHandler(InitPage);
        }
    }

    protected void InitPage(object sender, EventArgs e)
    {
        InitData();
    }

    protected void InitData()
    {
        String queryString = Request.QueryString["category_id"];  
        Int16 categoryId=0;
        if (!Int16.TryParse(queryString, out categoryId))
            return;

        DataSet ds = BLL.Command.getCategoryInfo(categoryId.ToString());
        String categoryName = ds.Tables[0].Rows[0].ItemArray[1].ToString();
        String categoryDiscription = ds.Tables[0].Rows[0].ItemArray[2].ToString();
        info_label.Text = "【" + categoryName + "】 " + categoryDiscription;

        int districtId = 0;
        Int16 servedDistrictId = 0;
        if (Session["RestaurantDistrictSelected"] != null)
        {
            districtId = Convert.ToInt16(Session["RestaurantDistrictSelected"].ToString());
        }

        if (Session["ServedDistrictSelected"] != null)
        {
            servedDistrictId = Convert.ToInt16(Session["ServedDistrictSelected"].ToString());
        }

        //categorydish_datalist.DataSource = BLL.Command.getCategoryDishListTops(categoryId, 0, districtId, servedDistrictId);
        //categorydish_datalist.DataBind();
    }

    protected void FilterSelectedIndexChanged(object sender, int districtId, Int16 servedDistrictId)
    {
        InitData();

        return;
    }

}
